package _00_Exercice;

import java.util.Scanner;

public class Method_Lianxi {
	public static void main(String[] args) {
		// 做了一个界面交互,写了点交互信息
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		System.out.print("请输入一个数 : ");
		int m = sc.nextInt();
		System.out.println("1-" + m + "的加和是 : " + m(m));
	}

	public static int m(int n) {
		int sum = 0;
		// 判断n的值,排除错误条件
		if (n < 1) {
			sum = -1;
		} else {
			for (int i = 1; i <= n; i++) {
				sum += i;
			}
		}
		return sum;
	}
}
